#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
    string longestPalindrome(string s) {
        int mi = 0, si = 0, max = 0;
        int n = s.length();
        int len[2005];
        for (int i = 0; i < 2 * n + 1; i++)
        {
            if (mi + si > i)
            {
                if (len[2 * mi - i] + i < mi + si) 
                {
                    len[i] = len[2 * mi - i];
                    continue;
                }
                int c = mi + si - i;
                while (i - c >= 0 && i + c < 2 * n + 1)
                {
                    if ((i + c) % 2 == 0)c++;
                    else if (s[(i + c) / 2] == s[(i - c) / 2])c++;
                    else break;
                }
                len[i] = c;
                if (i + c > mi + si)
                {
                    mi = i;
                    si = c;
                }
                continue;
            }
            int c = 1;
            while (i - c >= 0 && i + c < 2 * n + 1)
            {
                if ((i + c) % 2==0)c++;
                else if (s[(i + c) / 2] == s[(i - c) / 2])c++;
                else break;
            }
            len[i] = c;
            if (i + c > mi + si)
            {
                mi = i;
                si = c;
            }
        }
        for (int i = 0; i < 2 * n + 1; i++)
        {
            if (max < len[i])
            {
                max = len[i];
                mi = i;
            }
        }
        string ans = s.substr((mi - max + 1) / 2, max - 1);
        return ans;
    }
};

int main()
{
    string ss = "cc";
    Solution s;
    while(cin>>ss)cout << s.longestPalindrome(ss) << endl;
}